package net.pws.oos.biz.service.impl;

import net.pws.common.persistence.EntityManager;
import net.pws.oos.biz.model.SupervisionRecod;
import net.pws.oos.biz.query.SupervFinder;
import net.pws.oos.biz.service.SupervService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class DefaultSupervService implements SupervService {
    
    @Autowired
    private EntityManager entityManager;
    
    @Autowired
    private SupervFinder supervFinder;
            
    public SupervisionRecod saveSuperv(SupervisionRecod superv) {
        entityManager.persist(superv);
        return superv;
    }
//    
//    public SupervisionRecod assignSuperv(SupervisionRecod superv) {
//        superv.setRecordDate(new Date());
////        superv.setStatus(SupervisionRecod.ASSIGNED_STATUS);
//        saveSuperv(superv);
//        
//        List<Superv> children = supervFinder.getSubSupervList(superv.getId());
//        if (children != null && children.size() > 0) {
//            for (Superv child : children) {
//                child.setExecuteOrganization(superv.getExecuteOrganization());
//                child.setExecutePerson(superv.getExecutePerson());
//                child.setAssignedDate(superv.getAssignedDate());
//                child.setStatus(Superv.ASSIGNED_STATUS);
//                saveSuperv(child);
//            }
//        }
//        
//        return superv;
//    }

}
